package com.example.hospital.mapper;


import com.example.hospital.pojo.Position;
import org.apache.ibatis.annotations.*;

import java.util.List;
/*职位mapper接口*/
@Mapper
public interface PositionMapper {

    @Select("SELECT * FROM job_position WHERE id = #{id}")
    Position findById(Integer id);

    @Select("SELECT * FROM  job_position WHERE name = #{name}")
    Position findByName(Position position);

    @Select("SELECT * FROM job_position")
    List<Position> findAll();

    @Insert("INSERT INTO job_position(name, created_at, updated_at) VALUES(#{name}, NOW(), NOW())")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insertPosition(Position position);

    @Update("UPDATE job_position SET name=#{name}, updated_at=NOW() WHERE id=#{id}")
    void updatePosition(Position position);

    @Delete("DELETE FROM job_position WHERE id=#{id}")
    void deletePosition(Integer id);
}
